package algorithm.easy;

public class Solution83 {


    //输入：head = [1,1,2,3,3]
    //输出：[1,2,3]
    public static ListNode deleteDuplicates(ListNode head) {
        ListNode curr = head;
        if(curr==null || curr.next==null){
            return  curr;
        }
        ListNode next = curr;
        while (next!=null){
            int currV = curr.val;
            int nextV = next.val;
            if(nextV == currV){
                next = next.next;
            }else{
                curr = curr.next;
                curr.val = next.val;
                next = next.next;
            }
        }
        curr.next = null;
        head.print();
        return head;
    }

    public static  void main(String[] args){
        ListNode head = ListNode.init83();
        deleteDuplicates(head);
    }
}
